package cn.edu.tjufe.llp.tin.dto.part04;

import java.time.LocalDate;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.PastOrPresent;
import javax.validation.constraints.Size;

import com.fasterxml.jackson.annotation.JsonFormat;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BookDto {
	
    @Schema(description = "ID。查询到的记录中有ID；添加记录时没有ID；修改时，ID在Path中", 
            example = "123", required = false)
	private long id;
	
    @Schema(description = "书名", 
            example = "SpringBoot", required = true)
    @NotBlank(message = "书名不能为空")
    @Size(max = 100, message = "书名不能超过100字符")
	private String name;

    @Schema(description = "作者", 
            example = "佩奇", required = true)
    @NotBlank(message = "作者不能为空")
    @Size(max = 100, message = "作者不能超过50字符")
	private String author;
    
    @Schema(description = "出版社", 
            example = "XX出版社", required = true)
    @NotBlank(message = "出版社不能为空")
    @Size(max = 100, message = "出版社不能超过50字符")
	private String publisher;
    
	/**
	 * Publication Date
	 */
    @Schema(description = "出版日期", 
            example = "2021-06-01", required = true)
    @JsonFormat(pattern = "yyyy-MM-dd")
    @PastOrPresent(message = "出版日期不能是未来的日期")
	private LocalDate pubDate;
	
}
